package com.booth.base.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	public static final String YMHMS = "yyyy-MM-dd HH:mm:ss";
	public static String toDateStr(String date,String format) {
		SimpleDateFormat  df = new SimpleDateFormat(format);
		
		try {
			return toDateStr(df.parse(date),format);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
	public static String toDateStr(Date date,String format) {
		SimpleDateFormat  df = new SimpleDateFormat(format);
		
		return df.format(date);
	}
	public static Date toDate(String date,String format) {
		SimpleDateFormat  df = new SimpleDateFormat(format);
		
		try {
			return df.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
	public static Date toDate(Date date,String format) {
	
		return toDate(toDateStr(date,format),format);
	}

}
